package my.ezbart;

import java.util.ArrayList;

/**
 * @author Cecil Holmes
 * @version 0.1
 * 
 * TrainRetriever.java 
 * 
 * The purpose of this class is to retrieve data from a full BART schedule file/database and
 * create Train View objects from any trains matching the user requested criteria.
 */
public class TrainRetriever {
    private ArrayList<TrainView> dts = new ArrayList<TrainView>();
    private ArrayList<String[]> trains = new ArrayList<String[]>();
    private String origin = "";
    //private String destination = "";
    
    public TrainRetriever(String[] tripData) {
    	origin = tripData[0];
    	System.out.println(origin + "\n---------------------------");
    	//destination = tripData[1];
    	
    	this.getBARTData(tripData);
    	this.initTrains();
    }
    
    private void initTrains() {
		for (int i=0; i<trains.size(); i++)
			this.addTrain(trains.get(i));
	}

	public ArrayList<TrainView> getTrains() {
    	return dts;
    }
    
    public int getNumberOfTrains() {
    	return dts.size();
    }

    public TrainView getTrainView(int index) {
    	return dts.get(index);
    }
    
    private void getBARTData(String[] tripData) {
    	for(int i=0; i<4; i++)
    		trains.add(tripData);
    }
    
    public void addTrain(String[] newTrain) {
    	TrainView dt = new TrainView(dts.size(), newTrain);
    	dts.add(dt);
    }
}